﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;

namespace Chaotic.Core.Extension
{
    public class ImageSourceExtension
    {
        public static BitmapImage GetImageSource(string moduleName,string imagePath,int pixelHeight = 16,int pixelWidth = 16)
        {
            BitmapImage bitmapImage = new BitmapImage();
            bitmapImage.BeginInit();
            bitmapImage.DecodePixelHeight = pixelHeight;
            bitmapImage.DecodePixelWidth = pixelWidth;
            bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
            bitmapImage.UriSource = new Uri($"pack://application:,,,/{moduleName};Component/{imagePath}", UriKind.Absolute);
            bitmapImage.EndInit();
            bitmapImage.Freeze();
            return bitmapImage;
        }
    }
}
